home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / packet / p_aa4re / bb212src / bbsetup.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-03-12  |  16.9 KB  |  505 lines

  1. {$M 32768,32768,655360} {Stack, minheap, maxheap}
  2. PROGRAM bbsetup;
  3.  
  4. (*===========================================================================*)
  5. (* Set up parameters                                                         *)
  6. (*                                                                           *)
  7. (*   Copyright 1988, 1989, 1990, 1991, 1992 by H. Roy Engehausen.  All       *)
  8. (*   rights reserved.                                                        *)
  9. (*                                                                           *)
  10. (*===========================================================================*)
  11.  
  12. {$R+}    {Range checking on}
  13. {$B-}    {Boolean complete evaluation off}
  14. {$S+}    {Stack checking on}
  15. {$I+}    {I/O checking on}
  16. {$V+}    {String var checks}
  17. {$F+}    {Must have far calls}
  18. {$N-}    {No numeric coprocessor}
  19.  
  20. (*===========================================================================*)
  21. (* Globals                                                                   *)
  22. (*===========================================================================*)
  23.  
  24. USES
  25.   CRT,
  26.   DOS,
  27.   bbdummy,
  28.   bbfsm,
  29.   bbstr2;
  30.  
  31. (*===========================================================================*)
  32. (* Imported definitions                                                      *)
  33. (*===========================================================================*)
  34.  
  35. {$I BBOTYPE.PAS}
  36. {$I BBTIMEC.PAS}
  37.  
  38. (*===========================================================================*)
  39. (* Constants                                                                 *)
  40. (*===========================================================================*)
  41.  
  42. CONST
  43.   out_file_name = 'BBOPT.BB';
  44.   parm_max      = 100;
  45.  
  46. (*===========================================================================*)
  47. (* Types                                                                     *)
  48. (*===========================================================================*)
  49.  
  50. TYPE
  51.   parm_attr_type = SET OF
  52.                           (attr_did_this,
  53.                            attr_multiple_ok);
  54.  
  55.   parm_handle_type = RECORD
  56.                        parm_attr    : parm_attr_type;
  57.                        parm_name    : STRING[25];
  58.                        parm_type    : (parm_string,
  59.                                        parm_string_under,
  60.                                        parm_string_upper,
  61.                                        parm_path,
  62.                                        parm_file_not_exist,
  63.                                        parm_file,
  64.                                        parm_log,
  65.                                        parm_char_upper,
  66.                                        parm_byte,
  67.                                        parm_integer,
  68.                                        parm_word,
  69.                                        parm_long_int,
  70.                                        parm_boolean,
  71.                                        parm_user_class,
  72.                                        parm_speed,
  73.                                        parm_port_type,
  74.                                        parm_obsolete,
  75.                                        parm_access,
  76.                                        parm_str_chain,
  77.                                        parm_str_chain_up);
  78.  
  79.                        parm_addr    : POINTER;
  80.                        parm_str_len : WORD;
  81.  
  82.                        parm_lo      : LONGINT;
  83.                        parm_hi      : LONGINT;
  84.  
  85.                      END;
  86.  
  87.   parm_array       = ARRAY[1..parm_max] OF parm_handle_type;
  88.  
  89.   parm_array_ptr   = ^parm_array;
  90.  
  91. (*===========================================================================*)
  92. (* Vars                                                                      *)
  93. (*===========================================================================*)
  94.  
  95. VAR
  96.   b              : BOOLEAN;
  97.   bell_setting   : BOOLEAN;
  98.   code           : INTEGER;
  99.   display_sw     : BOOLEAN;
  100.   err_sw         : BOOLEAN;
  101.   err_save       : BOOLEAN;
  102.   fd_cnt         : BYTE;
  103.   fsb_flag       : BOOLEAN;
  104.   i_byte         : LONGINT;
  105.   i_loop         : BYTE;
  106.   i_value        : LONGINT;
  107.   in_file        : TEXT;
  108.   in_file_name   : STRING;
  109.   in_line        : STRING;
  110.   line_cnt       : WORD;
  111.   look           : SEARCHREC;
  112.   opt_buffer     : opt_file_rec;
  113.   out_file       : FILE OF opt_file_rec;
  114.   p_name         : STRING;
  115.   p_equal        : STRING;
  116.   p_value        : STRING;
  117.   port_chain     : port_block_ptr;
  118.   port_last_chn  : port_block_ptr;
  119.   port_cnt       : BYTE;
  120.   port_flag      : BOOLEAN;
  121.   port_parm_bcst : BYTE;
  122.   port_parm_call : BYTE;
  123.   port_parm_ring : BYTE;
  124.   t_str          : STRING;
  125.   this_port      : port_block_ptr;
  126.   this_fsb       : fsb_ptr;
  127.   w_count        : BYTE;
  128.   work_fsb       : file_subsys_block;
  129.   work_port      : port_block_type;
  130.   work_str       : STRING;
  131.   write_port     : port_block_ptr;
  132.  
  133.   main_parm_array : parm_array;
  134.   port_parm_array : parm_array;
  135.   file_parm_array : parm_array;
  136.  
  137. (*===========================================================================*)
  138. (* Check to see if this port is all set                                      *)
  139. (*===========================================================================*)
  140.  
  141. {$I BBSETUPM.PAS}         (* Miscellaneous routines                          *)
  142. {$I BBSETUPB.PAS}         (* Build beacon info                               *)
  143. {$I BBSETUPC.PAS}         (* Check port/file                                 *)
  144. {$I BBSETUPG.PAS}         (* Get Parm                                        *)
  145. {$I BBSETUPP.PAS}         (* Process lines                                   *)
  146. {$I BBSETUP0.PAS}         (* Initialize main parms                           *)
  147. {$I BBSETUP1.PAS}         (* Initialize port parms                           *)
  148. {$I BBSETUP2.PAS}         (* Initialize file parms                           *)
  149.  
  150. (*===========================================================================*)
  151. (* Main program begins here                                                  *)
  152. (*===========================================================================*)
  153.  
  154. BEGIN
  155.  
  156.   DIRECTVIDEO := FALSE;
  157.  
  158.   WRITELN;
  159.   WRITELN(this_bbs_version);
  160.   WRITELN;
  161.   WRITELN('Copyright 1988, 1989, 1990, 1991, 1992 by H.R. Engehausen.       ');
  162.   WRITELN('All rights reserved.                                             ');
  163.   WRITELN;
  164.  
  165.   (*-------------------------------------------------------------------------*)
  166.   (* Initialize                                                              *)
  167.   (*-------------------------------------------------------------------------*)
  168.  
  169.   display_sw     := FALSE;
  170.  
  171.   err_sw         := FALSE;
  172.  
  173.   port_flag      := FALSE;
  174.   port_chain     := NIL;
  175.   port_last_chn  := NIL;
  176.   port_cnt       := 0;
  177.  
  178.   fsb_flag       := FALSE;
  179.   fsb_base       := NIL;
  180.   fd_cnt         := 0;
  181.  
  182.   bell_setting   := FALSE;
  183.  
  184.   FILLCHAR(main_parm_array, SIZEOF(main_parm_array), CHR(0));
  185.   FILLCHAR(port_parm_array, SIZEOF(port_parm_array), CHR(0));
  186.   FILLCHAR(file_parm_array, SIZEOF(file_parm_array), CHR(0));
  187.  
  188.   (*-------------------------------------------------------------------------*)
  189.   (* Some fakeouts for general routines                                      *)
  190.   (*-------------------------------------------------------------------------*)
  191.  
  192.   active_tcb := NIL;
  193.  
  194.   (*-------------------------------------------------------------------------*)
  195.   (* Initial settings for main parms                                         *)
  196.   (*-------------------------------------------------------------------------*)
  197.  
  198.   FILLCHAR(opt_block, SIZEOF(opt_block), CHR(0));
  199.  
  200.   WITH opt_block DO
  201.     BEGIN;
  202.  
  203.       opt_hold_dupe_bid  := TRUE;
  204.       opt_kill_bbs_error := TRUE;
  205.       opt_direct_display := TRUE;
  206.       opt_direct_snow    := TRUE;
  207.       opt_error          := TRUE;
  208.       opt_time_status    := TRUE;
  209.       opt_blank_to_p     := FALSE;
  210.       opt_bid_for_p      := TRUE;
  211.       opt_bid_for_t      := TRUE;
  212.       opt_bid_for_blank  := TRUE;
  213.  
  214.       opt_types      := 'BPT';
  215.  
  216.       parm_file_ver  := this_bbs_parms;
  217.  
  218.       bcst_interval  := 255;
  219.       fwd_delay      := 10;
  220.       newuser_l_time := 255;
  221.       wakeup_intervl := 60;
  222.  
  223.       operator_color := default_data_color;
  224.       status_color   := default_spec_color;
  225.  
  226.       window_percent :=  50;
  227.       scroll_mon     := 100;
  228.       scroll_opr     := 100;
  229.       scroll_conn    :=  50;
  230.  
  231.       editor_free    := 10000;
  232.  
  233.       bpq_buff       := 360;
  234.  
  235.       yapp_time_exp  := 1;
  236.  
  237.     END;
  238.  
  239.   (*-------------------------------------------------------------------------*)
  240.   (* Setup parm fields                                                       *)
  241.   (*-------------------------------------------------------------------------*)
  242.  
  243.   main_parm_setup;
  244.   port_parm_setup;
  245.   file_parm_setup;
  246.  
  247.   (*-------------------------------------------------------------------------*)
  248.   (* Open the file                                                           *)
  249.   (*-------------------------------------------------------------------------*)
  250.  
  251.   in_file_name := '';
  252.  
  253.   FOR i_byte := 1 TO PARAMCOUNT DO
  254.     BEGIN;
  255.  
  256.       in_line    := PARAMSTR(i_byte);
  257.       in_line[2] := UPCASE(in_line[2]);
  258.  
  259.       IF in_line = '/D' THEN
  260.         display_sw := TRUE
  261.       ELSE
  262.         BEGIN;
  263.           IF in_file_name <> '' THEN
  264.             BEGIN;
  265.               WRITELN('Bad parameter list');
  266.               HALT;
  267.             END;
  268.           in_file_name := in_line;
  269.         END;
  270.     END;
  271.  
  272.   (*-------------------------------------------------------------------------*)
  273.   (* Open the file                                                           *)
  274.   (*-------------------------------------------------------------------------*)
  275.  
  276.   IF in_file_name = '' THEN
  277.     in_file_name := 'PARMS.BB';
  278.  
  279.   ASSIGN(in_file, in_file_name);
  280.  
  281.   {$I-}
  282.   RESET(in_file);
  283.   {$I+}
  284.   IF IORESULT <> 0 THEN
  285.     BEGIN;
  286.       WRITELN('***** Cannot open ', in_file_name);
  287.       HALT;
  288.     END;
  289.  
  290.   (*-------------------------------------------------------------------------*)
  291.   (* Process the lines                                                       *)
  292.   (*-------------------------------------------------------------------------*)
  293.  
  294.   line_cnt := 0;
  295.  
  296.   WHILE NOT EOF(in_file) DO
  297.     BEGIN;
  298.       READLN(in_file, in_line);
  299.       IF display_sw THEN
  300.         WRITELN(in_line);
  301.       line_cnt := line_cnt + 1;
  302.  
  303.       work_str := subword(@in_line, 1, 1);
  304.       IF (LENGTH(in_line) > 0)
  305.                  AND (work_str[1] <> '*')
  306.                  AND (work_str[1] <> ';') THEN
  307.         process_line;
  308.     END;
  309.  
  310.   (*-------------------------------------------------------------------------*)
  311.   (* Close file                                                              *)
  312.   (*-------------------------------------------------------------------------*)
  313.  
  314.   CLOSE(in_file);
  315.  
  316.   (*-------------------------------------------------------------------------*)
  317.   (* Check settings                                                          *)
  318.   (*-------------------------------------------------------------------------*)
  319.  
  320.   WRITELN;
  321.   WRITELN;
  322.  
  323.   IF port_flag THEN
  324.     err_disp('Missing ENDPORT');
  325.  
  326.   IF fsb_flag THEN
  327.     err_disp('Missing ENDFILE');
  328.  
  329.   IF port_cnt = 0 THEN
  330.     err_line('No ports defined');
  331.  
  332.   WITH opt_block DO
  333.     BEGIN;
  334.       IF max_task_no = 0 THEN
  335.         err_disp('Maximum tasks not set');
  336.       IF this_bb_name[0] = CHR(0) THEN
  337.         err_disp('SYSOP''s name is not set');
  338.       IF this_bb_loc[0] = CHR(0) THEN
  339.         err_disp('This mailbox''s location is not set');
  340.       IF this_bb_sign[0] = CHR(0) THEN
  341.         err_disp('This mailbox''s callsign is not set');
  342.       IF this_bb_addr[0] = CHR(0) THEN
  343.         err_disp('This mailbox''s address is not set');
  344.       IF this_bb_h[0] = CHR(0) THEN
  345.         err_disp('This mailbox''s hierarchical address is not set');
  346.       IF this_bb_h[1] <> '.' THEN
  347.   err_disp('This mailbox''s hierarchical address does not start with a period');
  348.       IF user_file_name[0] = CHR(0) THEN
  349.         err_disp('User file not set');
  350.       IF msg_file_name[0] = CHR(0) THEN
  351.         err_disp('Msg file not set');
  352.       IF msg_file_dir[0] = CHR(0) THEN
  353.         err_disp('Msg directory not set');
  354.       IF mess_fn[0] = CHR(0) THEN
  355.         err_disp('Message text library filename is not set');
  356.       IF route_fn[0] = CHR(0) THEN
  357.         err_disp('Route filename is not set');
  358.       IF path_fn[0] = CHR(0) THEN
  359.         err_disp('Path filename is not set');
  360.       IF help_fn[0] = CHR(0) THEN
  361.         err_disp('Help filename is not set');
  362.       IF dos_mess_fn[0] = CHR(0) THEN
  363.         err_disp('DOS Message filename is not set');
  364.       IF bid_fn[0] = CHR(0) THEN
  365.         err_disp('Bid filename is not set');
  366.       IF n_bid = 0 THEN
  367.         err_disp('Bid maximum is not set');
  368.       IF log_fn[0] = CHR(0) THEN
  369.         err_disp('Log filename is not set');
  370.       IF opt_trace AND (trace_file_name[0] = CHR(0)) THEN
  371.         err_disp('Trace on but file not given');
  372.  
  373.       IF language_list <> '' THEN
  374.         FOR i_loop := 2 TO LENGTH(language_list) DO
  375.           b := test_file(mess_fn + language_list[i_loop], FALSE);
  376.  
  377.     END;
  378.  
  379.   (*-------------------------------------------------------------------------*)
  380.   (* Build beacon info                                                       *)
  381.   (*-------------------------------------------------------------------------*)
  382.  
  383.   build_beacon_ports;
  384.  
  385.   (*-------------------------------------------------------------------------*)
  386.   (* If error then quit                                                      *)
  387.   (*-------------------------------------------------------------------------*)
  388.  
  389.   IF err_sw THEN
  390.     BEGIN;
  391.       WRITELN(' ');
  392.       WRITELN(' * * * WARNING * * *');
  393.       WRITELN(' ');
  394.       WRITELN('BBSETUP did not complete successfully.  The new parameters');
  395.       WRITELN('have been ignored.  Correct errors and rerun if you need the');
  396.       WRITELN('new parameters to run successfully');
  397.       WRITELN(' ');
  398.       WRITELN('===> BBOPT.BB has not been changed because of errors <===');
  399.       WRITELN('If you did not have a BBOPT.BB file before, you still don''t');
  400.       WRITELN('have one.');
  401.       WRITELN(' ');
  402.       SOUND(440);
  403.       DELAY(200);
  404.       NOSOUND;
  405.       HALT;
  406.     END;
  407.  
  408.   (*-------------------------------------------------------------------------*)
  409.   (* Some final adjustments please!                                          *)
  410.   (*-------------------------------------------------------------------------*)
  411.  
  412.   WITH opt_block DO
  413.     BEGIN;
  414.  
  415.       z_time_fwd := z_time_fwd * ticks_per_min;
  416.  
  417.       IF home_expires = 0 THEN
  418.         home_expires := 120;
  419.       home_expires := home_expires * ticks_per_day;
  420.  
  421.       IF b_fwd_stop = 0 THEN
  422.         b_fwd_stop := 20;
  423.       b_fwd_stop := b_fwd_stop * ticks_per_day;
  424.  
  425.       IF dflt_b_expire = 0 THEN
  426.         dflt_b_expire := 20;
  427.       dflt_b_expire := dflt_b_expire * ticks_per_day;
  428.  
  429.       IF this_bb_bid = '' THEN
  430.         this_bb_bid := this_bb_sign;
  431.  
  432.       IF sysop_sign = '' THEN
  433.         sysop_sign := this_bb_sign;
  434.  
  435.       IF bell_setting THEN
  436.         BEGIN;
  437.           bell_length1 := 100;
  438.           bell_length2 := 1;
  439.         END
  440.       ELSE
  441.         BEGIN;
  442.           bell_length1 := 1;
  443.           bell_length2 := 5;
  444.         END;
  445.  
  446.       IF (bpq_appl_num > 1) AND (bpq_appl_num < 5) THEN
  447.         bpq_appl_num := 1 SHL (bpq_appl_num-1)
  448.       ELSE
  449.         bpq_appl_num := 1;
  450.  
  451.     END;
  452.  
  453.   (*-------------------------------------------------------------------------*)
  454.   (* Write output file                                                       *)
  455.   (*-------------------------------------------------------------------------*)
  456.  
  457.   ASSIGN(out_file, out_file_name);
  458.   REWRITE(out_file);
  459.  
  460.   opt_block.port_count := port_cnt;
  461.   opt_block.fd_count := fd_cnt;
  462.  
  463.   FILLCHAR(opt_buffer, SIZEOF(opt_buffer), CHR(0));
  464.   opt_buffer.opt_block_file := opt_block;
  465.   WRITE(out_file, opt_buffer);
  466.  
  467.   WRITELN('*** Main parameters written ***');
  468.  
  469.   this_port  := port_chain;
  470.   write_port := @opt_buffer;
  471.  
  472.   WHILE this_port <> NIL DO
  473.     BEGIN;
  474.       FILLCHAR(opt_buffer, SIZEOF(opt_buffer), CHR(0));
  475.       opt_buffer.opt_port_file := this_port^;
  476.       WITH write_port^ DO
  477.         BEGIN;
  478.           port_sema := 0;
  479.           next_port := NIL;
  480.           rel_port  := NIL;
  481.         END;
  482.       WRITE(out_file, opt_buffer);
  483.       this_port := this_port^.next_port;
  484.     END;
  485.  
  486.   WRITELN('*** Port parameters written for ', port_cnt, ' port(s) ***');
  487.  
  488.   this_fsb := fsb_base;
  489.  
  490.   WHILE this_fsb <> NIL DO
  491.     BEGIN;
  492.       FILLCHAR(opt_buffer, SIZEOF(opt_buffer), CHR(0));
  493.       opt_buffer.opt_fd_file := this_fsb^;
  494.       WRITE(out_file, opt_buffer);
  495.       this_fsb := this_fsb^.next_fsb;
  496.     END;
  497.  
  498.   WRITELN('*** File parameters written for ', fd_cnt, ' file directories(s) ***');
  499.  
  500.   CLOSE(out_file);
  501.  
  502.   WRITELN('*** Parameters complete ***');
  503.  
  504. END.
  505.